package team2.arsystem.Controller;

import java.util.ArrayList;

import android.util.Log;
import team2.arsystem.Utilities.CommandConstants;

/*The static object applnController of this class is the facade controller serving to separate the GUI and the application logic. This class is implemented as a Singleton.*/
public class ApplicationController {
	
	private static ApplicationController applnController=new ApplicationController();
	
	private ApplicationController()
	{	
	}
	
	public static ApplicationController getApplicationController()
	{
		return applnController;
	}
	
	/*This method will be called by the classes in the GUI package. This method directs the request to the appropriate USe case Controller(AccountController, Transaction Controller)*/
	public boolean passCommand(String command,Object[] requestParams)
	{
		
		if(command == CommandConstants.loginUser)
		{
			return AccountController.getAccountController().loginUser(requestParams);
		}
		if(command == CommandConstants.createNewAccount)
		{
			return AccountController.getAccountController().createNewAccount(requestParams);
		}
		if(command == CommandConstants.addNewMember)
		{
			return AccountController.getAccountController().addNewMember(requestParams);
		}
		if(command == CommandConstants.addDebitTx)
		{
			return TransactionController.getTransactionController().addDebitTx(requestParams);
		}
		
		if(command == CommandConstants.logoutUser)
		{
			return AccountController.getAccountController().logoutUser();
		}
		
		return false;
	}
	
	/*Overloaded method when the return type is not a boolean but an ArrayList.*/
	public ArrayList<String> passCommandAndFetchResult(String command)
	{	
		
		if(command == CommandConstants.getMembers)
		{
			return AccountController.getAccountController().getMembers();
		}
		return null;
	}
	
	
	/*Overloaded method when the return type is not a boolean but an ArrayList of ArrayList.*/
	public ArrayList<ArrayList<String>> passCommandAndFetchMultipleResult(String command)
	{
		
		
		if(command == CommandConstants.getDebitReminders)
		{
			return TransactionController.getTransactionController().getDebitReminders();
		}
		return null;
	}

}
